import { Resource } from "../../mini3d";
import {StaticGroup} from "../../model";

export class Assets {
    onLoadCallback:any;
    instance:any;
    constructor(onLoadCallback) {
        this.onLoadCallback = onLoadCallback;
        this.init();
    }

    private init(){
        this.instance = new Resource();

        this.instance.on("onLoad", () => {
            this.onLoadCallback && this.onLoadCallback();
        });

        let assets = [
            { type: "Texture", name: "huiguang", path: StaticGroup.host.assetsManager.getImage('huiguang') },
            { type: "Texture", name: "rotationBorder1", path: StaticGroup.host.assetsManager.getImage('rotationBorder1') },
            { type: "Texture", name: "rotationBorder2", path: StaticGroup.host.assetsManager.getImage('rotationBorder2')  },
            { type: "Texture", name: "guangquan1", path:StaticGroup.host.assetsManager.getImage('guangquan1')  },
            { type: "Texture", name: "guangquan2", path: StaticGroup.host.assetsManager.getImage('guangquan2')  },
            { type: "Texture", name: "chinaBlurLine", path: StaticGroup.host.assetsManager.getImage('chinaBlurLine') },
            { type: "Texture", name: "ocean", path: StaticGroup.host.assetsManager.getImage('ocean') },
            { type: "Texture", name: "side", path:StaticGroup.host.assetsManager.getImage('side')  },
            { type: "Texture", name: "flyLine", path: StaticGroup.host.assetsManager.getImage('flyLine')  },
            { type: "Texture", name: "flyLineFocus", path:  StaticGroup.host.assetsManager.getImage('flyLineFocus') },
            { type: "Texture", name: "pathLine", path: StaticGroup.host.assetsManager.getImage('pathLine')  },
            { type: "Texture", name: "arrow", path:StaticGroup.host.assetsManager.getImage('arrow')  },
            { type: "Texture", name: "point", path:StaticGroup.host.assetsManager.getImage('point')  },
            // {
            //     type: "File",
            //     name: "areaInfo",
            //     path: `${StaticGroup.adcode}`,
            // },
            // {
            //     type: "File",
            //     name: "china",
            //     path: "中国",
            // },
            // {
            //     type: "File",
            //     name: "china_line",
            //     path: "中国",
            // },
            // {
            {
                type: "File",
                name: "areaInfo",
                path: `map/world/中国/广东省-area.json`,
            },
            {
                type: "File",
                name: "china",
                path: "geoJson",
            },
            {
                type: "File",
                name: "china_line",
                path: "geoJson",
            },
            // {
            //     type: "File",
            //     name: "areaInfo",
            //     path: `3dmap/assets/geoJson/${StaticGroup.adcode}_full.json`,
            // },
            // {
            //     type: "File",
            //     name: "china",
            //     path: "3dmap/assets/geoJson/100000_full.json",
            // },
            // {
            //     type: "File",
            //     name: "china_line",
            //     path: "3dmap/assets/geoJson/100000_full.json",
            // },
        ];
        this.instance.loadAll(assets);
    }
}